﻿package app.view.components.sections.expo.max 
{
	import app.model.types.SectionType;
	import app.model.vo.SectionVO;
	import app.view.components.buttons.GlamurBtnBase;
	import app.view.components.header.HeadMarkerBase;
	import app.view.components.sections.LabeledSectionBase;
	import app.view.events.UIEvent;
	import flash.events.MouseEvent;
	
	/**
	 * 1.1 ЭКСПО 2010
	 * firsoff maxim, snzflash.com, tel: +79222345364, skype: maxim.firsoff
	 */
	public class Expo2010MBase extends LabeledSectionBase
	{
		// app.view.components.sections.expo.max.Expo2010MBase
		
		public var expoConcept_Btn:GlamurBtnBase;
		public var pavilionMap_Btn:GlamurBtnBase;
		public var projectTeam_Btn:GlamurBtnBase;
		public var programmEvent_Btn:GlamurBtnBase;
		
		private var _btns:/*GlamurBtnBase*/Array;
		
		public function Expo2010MBase() 
		{
			super();
		}
		
		override protected function init():void 
		{
			super.init();
			
			_btns = [expoConcept_Btn, pavilionMap_Btn, projectTeam_Btn, programmEvent_Btn];
			
		};
		
		private function setEvents():void
		{
			expoConcept_Btn.addEventListener(MouseEvent.CLICK, onCLickExpoConcept);
			pavilionMap_Btn.addEventListener(MouseEvent.CLICK, onCLickPavilionMap);
			projectTeam_Btn.addEventListener(MouseEvent.CLICK, onCLickProjectTeam);
			programmEvent_Btn.addEventListener(MouseEvent.CLICK, onCLickProgrammEvent);
			
			
		}
		
		
		private function removeEvents():void
		{
			expoConcept_Btn.removeEventListener(MouseEvent.CLICK, onCLickExpoConcept);
			pavilionMap_Btn.removeEventListener(MouseEvent.CLICK, onCLickPavilionMap);
			projectTeam_Btn.removeEventListener(MouseEvent.CLICK, onCLickProjectTeam);
			programmEvent_Btn.removeEventListener(MouseEvent.CLICK, onCLickProgrammEvent);
			
		}
		
		
		override public function onDestroy():void 
		{
			// чистим что тут есть и вызываем супера
			removeEvents();
			
			expoConcept_Btn.destroy();
			pavilionMap_Btn.destroy();
			projectTeam_Btn.destroy();
			programmEvent_Btn.destroy();
			
			
			super.onDestroy();
		};
		
		override public function get data():Object { return _data; };
		
		override public function set data(value:Object):void 
		{
			super.data = value;
			
			////trace('data!!!',_data.data);
			
			setParamHead(HeadMarkerBase.BGD_RED);
			
			updateBtns();
			
			setEvents();
		};
		
		private function updateBtns():void
		{
			for each(var i:GlamurBtnBase  in _btns) 
			{
				//trace(i, i.setLang);
				i.setLang(data.lang);
			}
		}
		
		
		/**
		 * переход в концепцию участия
		 * @param	e
		 */
		private function onCLickExpoConcept(e:MouseEvent):void 
		{
			removeEvents();
			
			var obj:SectionVO = new SectionVO();
			obj.id = SectionType.PAGE_EXPO_CONCEPT;
			obj.currentId = id;
			obj.params = null;
			
			var ev:UIEvent = new UIEvent(UIEvent.SECTION_CHANGE);
			ev.data = obj;
			dispatchEvent(ev);
			
		}
		/**
		 * переход в карту павильона
		 * @param	e
		 */
		private function onCLickPavilionMap(e:MouseEvent):void 
		{
			removeEvents();
			
			var obj:SectionVO = new SectionVO();
			obj.id = SectionType.PAGE_EXPO_PAVILION_MAP;
			obj.currentId = id;
			obj.params = null;
			
			var ev:UIEvent = new UIEvent(UIEvent.SECTION_CHANGE);
			ev.data = obj;
			dispatchEvent(ev);
		}
		/**
		 * переход команду проекта
		 * @param	e
		 */
		private function onCLickProjectTeam(e:MouseEvent):void 
		{
			removeEvents();
			
			var obj:SectionVO = new SectionVO();
			obj.id = SectionType.PAGE_EXPO_PROJECT_TEAM;
			obj.currentId = id;
			obj.params = null;
			
			var ev:UIEvent = new UIEvent(UIEvent.SECTION_CHANGE);
			ev.data = obj;
			dispatchEvent(ev);
		}
		
		/**
		 * переход календарь
		 * @param	e
		 */
		private function onCLickProgrammEvent(e:MouseEvent):void 
		{
			removeEvents();
			
			var obj:SectionVO = new SectionVO();
			obj.id = SectionType.PAGE_EXPO_EVENTS_CALENDAR;
			obj.currentId = id;
			obj.params = null;
			
			var ev:UIEvent = new UIEvent(UIEvent.SECTION_CHANGE);
			ev.data = obj;
			dispatchEvent(ev);
		}
		
	}

}